using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebManager.Manager.Column
{
    public partial class Edit : System.Web.UI.Page
    {
        string OID = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            OID = Context.Request.QueryString["OID"];
            if (!Page.IsPostBack)
            {

                LYQ.BLL.SysObj bll = new LYQ.BLL.SysObj();
                LYQ.Model.SysObj model = bll.GetModel(OID);
                txtColumn.Text = model.OName;

                LYQ.BLL.SysType sysTypeBll = new LYQ.BLL.SysType();

                DataSet ds = sysTypeBll.GetList(" container = 1 ");
                drpType.DataTextField = "TName";
                drpType.DataValueField = "TID";
                drpType.DataSource = ds.Tables[0];
                drpType.DataBind();

                ListItem listItem = drpType.Items.FindByValue(model.TID);
                listItem.Selected = true;

                LYQ.Model.SysType modelSysType = sysTypeBll.GetModel(drpType.SelectedValue);
                Description.Text = modelSysType.TDescription;
            }
        }
        protected void Save_Click(object sender, EventArgs e)
        {

            LYQ.BLL.SysObj bll = new LYQ.BLL.SysObj();
            LYQ.Model.SysObj model = bll.GetModel(OID);
            model.OName = txtColumn.Text;
            model.TID = drpType.SelectedValue;
            bll.Update(model);

            string url = URLUtility.UrlBase + "/WebManager/manager/Column/List.aspx";
            Page.Response.Redirect(url);
        }

        protected void Cancel_Click(object sender, EventArgs e)
        {

            string url = URLUtility.UrlBase + "/WebManager/manager/Column/List.aspx";
            Page.Response.Redirect(url);
        }

        protected void drpType_SelectedIndexChanged(object sender, EventArgs e)
        {
            LYQ.BLL.SysType sysTypeBll = new LYQ.BLL.SysType();
            LYQ.Model.SysType model = sysTypeBll.GetModel(drpType.SelectedValue);
            Description.Text = model.TDescription;
        }
    }
}

